/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com */

/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef TRI_EXT_SLIDER_BAR_H_
#define TRI_EXT_SLIDER_BAR_H_

#include <iostream>
#include <vector>
#include <string>
#include <map>

//Include library header
#include "panel.h"
#include "button.h"

namespace tri {
namespace ui {

//======================================================================

/**
 * Component class used for user interface
 */
class extSliderBar : public tri::ui::extPanel {
public:
	extSliderBar();
	virtual ~extSliderBar();
	
	/**
	 * Get the current slider value
	 * @return Curretn value
	 */
	float getValue();
	
	/**
	 * Set the current slider value
	 */
	void setValue(float v);
	
	/**
	 * Set the maximum vlaue range
	 */
	virtual void setMaximumValue(float v);
	
	/**
	 * Set the maximum vlaue range
	 */
	virtual void setMinimumValue(float v);
	
	/**
	 * Get the maximum value range
	 */
	float getMaximumValue();
	
	/**
	 * Get the maximum value range
	 */
	float getMinimumValue();

	
	void setSliderButtonWidth(float w);
	void setSliderButtonHeight(float h);
	
	virtual void setStyle(std::string style);
	
	virtual void update();
	
	/**
	 * Set hoe sensitive the slider is. The number provided 
	 * is how much the slider moves per pixel movement of the mouse.
	 */
	void setSliderSensitivity(float s);
	
protected:
	virtual void updateSliderPosition()=0;

	extButton mSliderButton;
	float mSensitivity;
	float mValue;
	float mMaxValue;
	float mMinValue;
};


/**
 * Horizontal Slider implmentation 
 */
class extHorizontalSlider : public extSliderBar{
public:
	extHorizontalSlider();
	virtual ~extHorizontalSlider();
	
	virtual void update();
	
private:
	class HorizontalSliderButtonManager : public sigslot::has_slots<sigslot::multi_threaded_local>{
	public:
		HorizontalSliderButtonManager(extHorizontalSlider* slider = NULL);
		virtual ~HorizontalSliderButtonManager();
		
		void onMouseDrag();
		
		extHorizontalSlider* mSlider;
	};
	
	HorizontalSliderButtonManager* mHorizontalSliderButtonManager;
	
protected:
	virtual void updateSliderPosition();
};

/**
 * Horizontal Slider implmentation 
 */
class extVerticalSlider : public extSliderBar{
public:
	extVerticalSlider();
	virtual ~extVerticalSlider();
	
	virtual void update();
	
private:
	class VerticalSliderButtonManager : public sigslot::has_slots<sigslot::multi_threaded_local>{
	public:
		VerticalSliderButtonManager(extVerticalSlider* slider = NULL);
		virtual ~VerticalSliderButtonManager();
		
		void onMouseDrag();
		
		extVerticalSlider* mSlider;
	};
	
	VerticalSliderButtonManager* mVerticalSliderButtonManager;
	
protected:
	virtual void updateSliderPosition();
};


}
}

#endif
